fix(error): return TLS 1.2 PRF setup errors - #14
Merged
Conversation
thieman
marked this pull request as ready for review
June 23, 2026 19:27
tobz
reviewed
Jun 23, 2026
| output: &mut [u8; 48], | ||
| kx: Box<dyn ActiveKeyExchange>, | ||
| peer_pub_key: &[u8], | ||
| output: &mut [u8], |
Member
There was a problem hiding this comment.
I'm not sure I understand why we're switching to a variable-length slice here... 🤔
Contributor
Author
There was a problem hiding this comment.
[GPT 5.5] This is shared with for_secret, whose rustls trait signature is already &mut [u8]. The for_key_exchange method still receives &mut [u8; 48]; before this PR it immediately called for_secret, which coerced that fixed array to the same slice type. So this does not broaden the key-exchange caller contract, it just avoids duplicating the CNG KDF implementation. I checked the PR diff and did not find another introduced fixed-array-output helper pattern that needs the same treatment.
tobz
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduce panic surface in the TLS 1.2 PRF path:
rustls::Errorfrom the falliblePrf::for_key_exchangepath if CNG KDF setup or derivation fails.Prf::for_secretmethod, but route it through the same fallible helper and use an explicit invariantexpectmessage rather than opaque CNG unwraps.This PR intentionally avoids changing other infallible rustls trait implementations where the API has no
Resultreturn. Those sites need separate design/review if we want to preflight or restructure them.Testing
cargo fmt -- --checkcargo check --target x86_64-pc-windows-msvccargo check --target x86_64-pc-windows-msvc --no-default-featurescargo check --features fips --target x86_64-pc-windows-msvc(passes with pre-existingkx.rsdead-code warnings)cargo clippy --target x86_64-pc-windows-msvc -- -D warningsgit diff --checkWindows CI should run the unit tests. Local macOS cannot compile Windows-target test dependencies because
aws-lc-sysneeds Windows SDK headers.